package com.cnh.o2o;

import org.springframework.boot.SpringApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.cnh.o2o.util.wechat.WechatUtil;
import com.cnh.o2o.util.wechat.menu.NormalAccessToken;

@RestController
public class Hello {
	
	@RequestMapping(value="/hello", method=RequestMethod.GET)
	public String hello() {
		return "hello springboot";
	}
	
	public static void main(String[] args) throws Exception {
		try {
			NormalAccessToken token = WechatUtil.geNormalAccessToken();
			System.out.println("token:" + token.getToken());
			System.out.println("有效时间:" + token.getExpiresIn());
			
			String menu = JSONObject.toJSONString(WechatUtil.initMenu());
			int result = WechatUtil.createMenu(token.getToken(), menu);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	
	}
	

}
